﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RelationExpertSystem.Relation
{
    public class Grandmother : RelationBase
    {
        private static Grandmother _singleton = new Grandmother();
        public static Grandmother Instance
        {
            get { return _singleton; }
        }

        private Grandmother() { }

        public override bool IsRelated(Person a, Person b)
        {
            // b is a's Grandmother IFF b is female and b is a's grandparent
            return b.Sex == Sex.Female && a.KnownRelation(Grandparent.Instance, b);
        }

        public override IEnumerable<IRelation> GetDependencies()
        {
            return new HashSet<IRelation>(new IRelation[] { Grandparent.Instance });
        }
    }
}
